package com.bsoft.project.base;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 褚国强
 * @Date: 2020/07/13/15:09
 * @Description:
 * 全局拦截
 */
@Component
@WebFilter(filterName = "WarpperFilter",urlPatterns = "/*")
public class WarpperFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
            throws IOException, ServletException {
        //获取路径
        String url  = ((HttpServletRequest)servletRequest).getRequestURI().substring(0,5);
        System.out.println(">>>>>进入工程>>>>请求路径>>"+url);
        filterChain.doFilter(servletRequest,servletResponse);
//        if ("/edms".equals(url) || "/favi".equals(url) || "/hyst".equals(url) || "/actu".equals(url)){
//            filterChain.doFilter(servletRequest,servletResponse);
//        }else {
//            throw new BizException("ERROR_1000_0001","filter内部抛出异常>>>>>路径中0-5必须是/udsi");
//        }

    }

    @Override
    public void destroy() {

    }
}
